package mysale.service.impl;

import mysale.dao.CartDao;
import mysale.dao.UserDao;
import mysale.dao.impl.CartDaoImpl;
import mysale.dao.impl.UserDaoImpl;
import mysale.pojo.Cart;
import mysale.service.CartService;
import mysale.util.JDBCUtil;

import java.sql.Connection;
import java.util.List;

/**
 * @author SnakeWoodMan
 * @create 2020-12-29 17:44
 */
public class CartServiceImpl implements CartService {
    private Connection conn ;
    private CartDao cartDao = new CartDaoImpl(conn);

    @Override
    public List<Cart> getallinfo(String uid) {
//        conn = JDBCUtil.getConnection();
        List<Cart> cartList = cartDao.getAllcartinfo(uid);
        return cartList;
    }

    @Override
    public List<Cart> getbuyinfo(String uid) {
        List<Cart> cartList = cartDao.getbuycartinfo(uid);
        return cartList;
    }

    @Override
    public List<Cart> getnotbuyinfo(String uid) {
        List<Cart> cartList = cartDao.getnotbuycartinfo(uid);
        return cartList;
    }

    @Override
    public List<Cart> getcartbyuiffid(Cart cart) {
        List<Cart> cartList = cartDao.getCartbyuidfid(cart);
        return cartList;
    }

    @Override
    public boolean addGoodsToCart(Cart cart) {
        boolean result = cartDao.insertCart(cart);
        return result;
    }

    @Override
    public boolean deleteGoodsFromCart(Cart cart) {
        boolean result = cartDao.deleteCart(cart);
        return result;
    }

    @Override
    public boolean buyGoodsFromCart(Cart cart) {
        boolean result = cartDao.buyCart(cart);
        return result;
    }

    @Override
    public boolean subGoodsStock(Cart cart) {
        boolean result = cartDao.subtractCartStock(cart);
        return result;
    }

    @Override
    public boolean updateGoodsNum(Cart cart) {
        boolean result = cartDao.updateCart(cart);
        return result;
    }
}
